<template>
  <div class="cart">
    <header>
      <section>
        <router-link to="/home"><span class="icon">&#xe6b0;</span></router-link></section>
      <h1>购物车</h1>
    </header>
    <div class="main">
      <div class="cartBox">
        <div class="storename">
          <label @click="changeImg">
            <img src="../assets/icon_select01.png" v-if="isShow"/>
            <img src="../assets/icon_select02.png" v-else/>
            <p>1药网</p>
          </label>
        </div>
        <div class="storeCont">
          <label @click="changeImg">
            <img src="../assets/icon_select01.png" v-if="isShow"/>
            <img src="../assets/icon_select02.png" v-else/>
          </label>
          <div class="imgBox">
            <img src="../assets/120_120_002.jpg" />
          </div>
          <div class="textBox">
            <p class="title">修正西洋参 枸杞子提取物软胶囊 0.5g/粒*100粒</p>
            <p class="price"><span class="price_l">￥</span></p>
            <button type="button" class="btn" @click="less">-</button>
            <span v-module="countC" class="conNum">{{ count }}</span>
            <button type="button" class="btn" @click="more">+</button>
          </div>
        </div>
      </div>
      <div class="tatolBox">
        <ul>
          <li>
            <p class="tit">重量</p>
            <p class="num" >{{ weight }}kg</p>
          </li>
          <li>
            <p class="tit">优惠</p>
            <p class="num">￥0.00</p>
          </li>
          <li>
            <p class="tit">商品金额</p>
            <p class="num" >￥{{ price }}</p>
          </li>
        </ul>
      </div>
      <div class="cartBox">
        <ul>
          <li>
            <span class="tit">总重量：</span>
            <span class="num1" >{{ weight*count }}kg</span>
          </li>
          <li>
            <span class="tit">优惠：</span>
            <span class="num1">-￥0.00</span>
          </li>
          <li>
            <span class="tit">商品金额：</span>
            <span class="num1">￥{{ countC * price }}</span>
          </li>
          <li>
            <span class="tit">应付金额：</span>
            <span class="num3"><b>￥{{ countC * price }}</b></span>
          </li>
        </ul>
      </div>
    
      <div class="concat">
        <div class="concat_box">
          <span class="tit">应付金额：</span>
          <span class="pri">￥{{ countC * price }}</span>
          <span class="tit1">不含运费</span>
          <button class="foo_btn">去结算</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'hello',
  data () {
    return {
      isShow: false,
      // 总价钱
      allCount: 10,
      // 件数
      count: 1,
      // 价格
      price: 10,
      weight: 12
    }
  },
  methods: {
    changeImg() {
      if( this.isShow == false ){
        this.isShow = true
      }else{
        this.isShow = false
      } 
    },
    less() {
      return this.count--;
    },
    more() {
      return this.count++;
    }
  },
  computed: {
    // 对件数进行判断
    countC: {
      get() {
        return this.count
      },
      set(newV) {
        if( newV >= 10){
            this.count = 10
        }else if( newV <= 0){
          this.count = 1
        }else {
            this.count = newV
        }
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

header{
    height: 1.2rem;
    width: 100%;
    position: fixed;
    top: 0;
    background-color: #0093e7;
    line-height: 1.7;
    min-height: 1.25333rem;
    z-index: 2;
}
header h1{
    font-size: .48rem;
    font-weight: normal;
    text-align: center;
    color: #fff;
    line-height: 1.2;
    padding-top: .32rem;
}
.icon{
    font-family: 'iconfont'; 
    position: absolute;
    left:.1333rem;
    font-size:.88rem;
    color: #fff;
    line-height: 1.2rem;
}
.cart_Btn{
  width: 3.73rem;
  height: 1.2rem;
  background-color: #0099f1;
  display: block;
  font-size: .4rem;
  color: #fff;
  line-height: 1.17rem;
  text-decoration: none;
  border-radius: .08rem;
  margin: 0 auto;
  margin-bottom: 1rem;
}
.main{
  background: #efefef;
  padding-top: 1.3rem;
}
.cartBox{
  width: 9.5rem;
  height: 4.16rem;
  margin: .27rem;
  border: 1px solid #e8e8e8;
  border-top: 2px solid #0099f1;
  background-color: #fff;
}
.storename{
  height: 1.226rem;
  font-size: .427rem;
  border-bottom: 1px solid #e8e8e8;
  display: block;
}
.storename>label{
  border-radius: 0;
  display: inline-block;
  position: relative;
}
.storename>label img{
  width: .48rem;
  position: absolute;
  left: .3rem;
  top: .4rem;
}
.storename>label p{
  margin: .35rem 0 0 1rem;
}
.storeCont{
  padding: 10px 10px 10px 50px;
  position: relative;
  clear: both;
}
.imgBox img{
  height: 1.34rem;
}
.storeCont>label img{
  width: .48rem;
  position: absolute;
  top: 35%;
  left: .3rem;
}
.storeCont .textBox{
  width: 6.14rem;
  position: absolute;
  right: .1rem;
  top:.3rem;
}
.btn{
  width: .7rem;
  height: .7rem;
  background: #efefef;
  border: none;
  border: 1px solid #efefef;
  outline: none;
  float: left;
}
.textBox .conNum{
  width: 1.55rem;
  height: .6rem;
  line-height: 1.5;
  border: 1px solid #efefef;
  float: left;
  text-align: center;
  font-size: .4rem;
}
.tatolBox{
  background-color: #f8f8f8;
  color: #6c6c6c;
  font-size: 13px;
}
.tatolBox ul{
  height: 1.6rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.tatolBox ul li p{
  text-align: center;
  font-size: .38rem;
  line-height: 2;
}
.tatolBox ul li .num{
  color: #e72419;
}
.cartBox .num1{
  position: absolute;
  right: 1rem;
}
.cartBox .num3{
  position: absolute;
  right: 1rem;
  color: #e72419;
}
.cartBox ul li{
  color: #6c6c6c;
  line-height: 2.8;
}
.cartBox ul li:last-of-type{
  font-size: .4rem;
}
.concat{
   height: 2.13rem;
   margin-top: 2rem;
}
.concat_box{
  font-size: 15px;
  color: #5e5e5e;
  background-color: #efefef;
  border: 1px solid #d0d0d0;
  border-left: none;
  border-right: none;
  padding: .5rem;
  position: relative;
}
.concat_box .tit1{
  margin-left: .5rem;
}
.concat_box .pri{
  color: #e72419;
  font-weight: 700;
  font-size: .5rem;
}
.concat_box .foo_btn{
  position: absolute;
  right: .3rem;
  width: 3rem;
  height: 1rem;
  top: .3rem;
  color: #fff;
  background-color: #e72419;
  border-radius: 3px;
  border: 0;
  font-size: .45rem;
}
</style>
